#!/bin/bash
if [ $# -lt 1 ];then
  echo "usage: sh gitlog.sh /home/kernel/driver/i2c"
  exit 1
fi
src_path=$1
work_path=$(pwd)
cd $src_path
echo "workpath:$work_path, src_path:$src_path"
git log --oneline . > $work_path/i2clogtmp
rm -rf $work_path/i2clog

while read rows
do
#  echo "$PWD"
#  echo "$rows"
  commit_id=$(echo $rows| cut -f 1 -d ' ')
  tag=$(git describe $commit_id)
  message=${rows:13:${#rows}-13}


   echo "$commit_id $tag $message"
   echo "$commit_id $tag $message"  >> $work_path/i2clog

done < $work_path/i2clogtmp

rm -rf $work_path/i2clogtmp